public class Demo05 {

    public static void main(String[] args) {
        // 插入排序
        int[] arr = new int[]{3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48};
        for (int i = 1; i < arr.length; i ++) {
            int current = arr[i];
            int prevIndex = i - 1;
            while (prevIndex >= 0 && current < arr[prevIndex]) {
                arr[prevIndex + 1] = arr[prevIndex];
                prevIndex--;
            }
            arr[prevIndex + 1] = current;
        }
        for (int a : arr) {
            System.out.println(a);
        }
    }
}
